package com.tilas.service.impl;

import com.tilas.mapper.EmpMapper;
import com.tilas.pojo.JobOption;
import com.tilas.service.ReportSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportSerivceImpl implements ReportSerivce {

    @Autowired
    private EmpMapper empMapper;

    @Override
    public JobOption getEmpJobDate() {
        //1.调用Mapper接口，获取统计数据
        List<Map<String,Object>> list =  empMapper.countEmpJobDate();
        //2.组装结果并返回

        List<Object> jobList = list.stream().map(dataMap ->dataMap.get("pos")).toList();
        List<Object> dataList = list.stream().map(dataMap ->dataMap.get("num")).toList();

        return new JobOption(jobList,dataList);
    }

    @Override
    public List<Map<String, Object>> getEmpGenderData() {

        return empMapper.countEmpGenderDate();
    }
}
